package com.xuecheng.content.service;

import com.xuecheng.commons.model.dto.CourseAuditDto;
import com.xuecheng.commons.model.dto.CourseBaseDto;
import com.xuecheng.commons.model.dto.CourseDto;
import com.xuecheng.commons.model.dto.PageRequest;
import com.xuecheng.commons.model.vo.CourseBaseVo;
import com.xuecheng.commons.model.vo.PageResponseResult;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.content.domain.CourseBase;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xuecheng.web.exceptions.BusinessException;
import io.minio.errors.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 * <p>
 * 课程基本信息 服务类
 * </p>
 *
 * @author 七安
 * @since 2022-09-17
 */
public interface CourseBaseService extends IService<CourseBase> {

    /**
     * 分页查询课程
     *
     * @param courseDto   接收部分查询条件，例如名字，状态
     * @param pageRequest 分页数据
     * @return 课程列表
     */
    PageResponseResult findClassList(CourseDto courseDto, PageRequest pageRequest);

    /**
     * 课程封面上传
     *
     * @param uploadFile 封面文件
     * @return 上传后的地址
     */
    String fileUpload(MultipartFile uploadFile) throws IOException, ServerException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException;

    /**
     * 添加课程
     *
     * @param courseBaseDto 课程信息
     * @return 添加完成后的id
     */
    CourseBaseVo insertCourse(CourseBaseDto courseBaseDto) throws BusinessException;

    /**
     * 根据ID删除
     *
     * @param courseId 要删除的id
     * @return 删除结果
     * @throws BusinessException 删除失败
     */
    void deleteCourseById(String courseId) throws BusinessException;

    /**
     * 根据id修改课程
     *
     * @param courseBaseDto 要修改的内容
     * @return 课程id
     */
    Long updateCourseById(CourseBaseDto courseBaseDto) throws BusinessException;

    /**
     * 提交审核
     * @param courseBaseId 要提交的课程id
     * @return 结果
     */
    void commitVerify(Long courseBaseId) throws BusinessException;

    /**
     * 审核课程
     * @param courseAuditDto 审核的意见和状态
     */
    void verifyCourse(CourseAuditDto courseAuditDto) throws BusinessException;

    /**
     * 课程下架
     *
     * @param courseId 课程id
     * @return 结果
     */
    ResponseResult courseSoldOut(Long courseId) throws BusinessException, ServerException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException;
}
